package com.evaluation_system.Task;

import com.evaluation_system.service.NonceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class NonceCleanupTask {

    @Autowired
    private NonceService nonceService;

    @Scheduled(cron = "0 0 */2 * * ?")
//    @Scheduled(cron = "0 */1 * * * ?")
//    @Scheduled(cron = "*/10 * * * * ?")
    public void cleanup() {
        log.info("Cleaning up expired nonces...");
        nonceService.clearExpiredNonces();
    }
}